package zj.it.bhne.gridengineeringsurvey.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;

import zj.it.bhne.gridengineeringsurvey.BaseActivity;
import zj.it.bhne.gridengineeringsurvey.R;
import zj.it.bhne.gridengineeringsurvey.myutils.MyUtils;
import zj.it.bhne.gridengineeringsurvey.myutils.ThreadManager;

import static zj.it.bhne.gridengineeringsurvey.myutils.ThreadManager.getThreadPool;

public class ForgetPassActivity extends BaseActivity implements View.OnClickListener {

    private Context context;
    private EditText forget_ed_name;
    private EditText forget_ed_pass;
    private int number;

    private Handler handler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_forget_pass);
        context = this;
        initView();
    }

    private void initView() {
        Intent intent = getIntent();
        number = intent.getIntExtra("number",0);
        ImageButton activity_ib_back = findViewById(R.id.activity_ib_back);
        TextView activity_tv_title = findViewById(R.id.activity_tv_title);
        TextView activity_tv_save = findViewById(R.id.activity_tv_save);
        activity_tv_save.setVisibility(View.GONE);
        activity_tv_title.setText("忘记密码");
        activity_ib_back.setOnClickListener(this);
        forget_ed_name = findViewById(R.id.forget_ed_name);
        forget_ed_pass = findViewById(R.id.forget_ed_pass);
        Button forget_btn_save = findViewById(R.id.forget_btn_save);
        forget_btn_save.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.activity_ib_back:
                Intent intent = new Intent(context, BottomActivity.class);
                intent.putExtra("item_id", 3);
                startActivity(intent);
                break;
            case R.id.forget_btn_save:
                if ("".equals(forget_ed_name.getText().toString().trim())||"".equals(forget_ed_pass.getText().toString().trim())){
                    MyUtils.getToast(context,"请输入完整信息");
                }else {
                    Runnable runnable = new Runnable() {
                        @Override
                        public void run() {

                        }
                    };
                    ThreadManager.ThreadPool threadPool = getThreadPool();
                    threadPool.execute(runnable);
                }
                break;
        }
    }

    /**
     * 跳转到主界面
     */
    private void getIntents() {
        Intent intent;
        if (number == 2) {
            intent = new Intent(context, AccountActivity.class);
        } else {
            intent = new Intent(context, BottomActivity.class);
        }
        intent.putExtra("item_id", 3);
        startActivity(intent);
    }

}
